using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace VotingSystem.Models
{
    public class SurveyQuestion
    {
        [Key]
        public int Id { get; set; }

        [Required]
        public int SurveyId { get; set; }

        [Required]
        [StringLength(500)]
        public string QuestionText { get; set; } = string.Empty;

        [Required]
        public QuestionType Type { get; set; }

        public bool IsRequired { get; set; }

        public int Order { get; set; }

        // 多选题选择限制
        public int? MinSelectionCount { get; set; }
        public int? MaxSelectionCount { get; set; }
        public int? ExactSelectionCount { get; set; }

        [ForeignKey("SurveyId")]
        public Survey? Survey { get; set; }

        public virtual ICollection<QuestionOption> Options { get; set; } = new List<QuestionOption>();

        public virtual ICollection<QuestionResponse> Responses { get; set; } = new List<QuestionResponse>();
    }

    public enum QuestionType
    {
        SingleChoice = 0,    // 单选题
        MultipleChoice = 1,  // 多选题
        Text = 2,           // 填空题
        Rating = 3          // 评分题
    }
} 